import request from '@/utils/request'
//import qs from 'qs'

//批次采购列表
export function purchasePage(params:any){
    return request({
      url: '/purchase/nclist',
      method: 'get',
      params,
    })
}
//根据已知的供应商id和业务id回显（普通填写）
export function purchaseInf(supplierId,businessId){
  return request({
    url: `/purchase/nbget1?id=${businessId}&supplierId=${supplierId}`,
    method: 'get',
  })
}
//批次采购信息添加（普通填写）
export function purchaseCreate2(supplierId,businessId,data?:any){
  return request({
    url: `/purchase/ncadd1?supplierId=${supplierId}&businessId=${businessId}`,
    method: 'post',
    data,
  })
}
//获取历史供应商
export function supplierHistory(params:any){
  return request({
    url: '/purchase/ncget3',
    method: 'get',
    params,
  })
}
//获取历史产品
export function productHistory(params:any){
  return request({
    url: '/purchase/ncget4',
    method: 'get',
    params,
  })
}
//根据批次采购id回显（快捷填写）
export function purchaseDetails(params:any){
  return request({
    url: '/purchase/ncgett',
    method: 'get',
    params,
  })
}
//批次采购信息添加（快捷填写）
export function purchaseCreate(data?:any){
    return request({
      url: '/purchase/ncadd',
      method: 'post',
      data,
    })
}
//获取最佳批次采购量
export function purchaseEoq(supplierId,businessId){
  return request({
    url: `/purchase/nccalculate?supplierId=${supplierId}&businessId=${businessId}`,
    method: 'get',
  })
}
//批次采购信息编辑
export function purchaseUpdate(id,data?:any){
    return request({
      url: `/purchase/ncupdate?id=${id}`,
      method: 'put',
      data,
    })
}
//批次采购信息删除
export function purchaseDelete(params?:any){
    return request({
      url: '/purchase/ncdelete',
      method: 'delete',
      params,
    })
}
//批次采购记录入库信息（快捷）
export function ifInBound(id){
  return request({
    url: `/purchase/used?id=${id}`,
    method: 'get',
  })
}
//批次采购供应商评价
export function purchaseEvaluate(supplierId,id,data?:any){
  return request({
    url: `/purchase/ncupdateScore?supplierId=${supplierId}&id=${id}`,
    method: 'post',
    data
  })
}
//供应商列表
export function supplierPage(params:any){
  return request({
    url: '/purchase/sget',
    method: 'get',
    params,
  })
}
//供应商表单新建
export function supplierAdd(data?:any){
  return request({
    url: '/purchase/sadd',
    method: 'post',
    data,
  })
}
//供应商表单详情
export function supplierDetails(params:any){
  return request({
    url: '/purchase/sgetById',
    method: 'get',
    params,
  })
}
//供应商表单删除
export function supplierDelete(params?:any){
  return request({
    url: '/purchase/sdelete',
    method: 'delete',
    params,
  })
}
//供应商表达编辑
export function supplierUpdate(id,data?:any){
  return request({
    url: `/purchase/supdate/?id=${id}`,
    method: 'put',
    data,
  })
}
//业务列表
export function businessPage(supplierId){
  return request({
    url: `/purchase/nb?supplierId=${supplierId}`,
    method: 'get',
  })
}
//新增业务
export function businessAdd(supplierId,data?:any){
  return request({
    url: `/purchase/nbadd?supplierId=${supplierId}`,
    method: 'post',
    data,
  })
}
//删除业务
export function businessDelete(supplierId,id){
  return request({
    url: `/purchase/nbdelete?id=${id}&supplierId=${supplierId}`,
    method: 'delete',
  })
}
//业务详情
export function businessDetails(params:any){
  return request({
    url: '/purchase/nbget',
    method: 'get',
    params,
  })
}
//编辑业务
export function businessUpdate(id,supplierId,data?:any){
  return request({
    url: `/purchase/nbedit?id=${id}&supplierId=${supplierId}`,
    method: 'put',
    data,
  })
}
//采购成本列表
export function costPage(params:any){
  return request({
    url: '/purchase/clist',
    method: 'get',
    params,
  })
}
//获取全部供应商名称
export function getSupplierName(params:any){
  return request({
    url: '/purchase/cget',
    method: 'get',
    params,
  })
}
//根据供应商获取对应供应商全部业务
export function getBusinessName(supplierId){
  return request({
    url: `/purchase/cgett?supplierId=${supplierId}`,
    method: 'get',
  })
}
//采购成本表单新建
export function costAdd(businessId,supplierId,data?:any){
  return request({
    url: `/purchase/cadd?businessId=${businessId}&supplierId=${supplierId}`,
    method: 'post',
    data,
  })
}
//采购成本表单详情
export function costDetails(params:any){
  return request({
    url: '/purchase/cgetById',
    method: 'get',
    params,
  })
}
//采购成本表单详情
export function costDetailsbyId(supplierId,businessId){
  return request({
    url: `/purchase/cgetById2?supplierId=${supplierId}&businessId=${businessId}`,
    method: 'get',
  })
}
//成本管理表单删除
export function costDelete(params?:any){
  return request({
    url: '/purchase/cdeleteById',
    method: 'delete',
    params,
  })
}
//编辑采购成本管理表
export function costUpdate(supplierId,businessId,data?:any){
  return request({
    url: `/purchase/cupdateBySupplierIdAndBusinessId?supplierId=${supplierId}&businessId=${businessId}`,
    method: 'put',
    data,
  })
}
//采购统计详情
export function statistics(){
  return request({
    url: `/purchase/nn`,
    method: 'get',
  })
}
//采购产品与原料入库(判断是否存在表)
export function inBound(data?:any){
  return request({
    url: `/inventory/products/order`,
    method: 'post',
    data,
  })
}
//采购产品与原材料入库
export function productInBound(data?:any){
  return request({
    url: `/inventory/approvement/createApprovement`,
    method: 'post',
    data,
  })
}
//获取用户自定义规格表
export function getSpecificationForm(){
  return request({
    url: `/inventory/specification/getAllSpecifications`,
    method: 'get',
  })
}
//更新审核状态
export function updateAdjustmentStatus(id,data?:any){
  return request({
    url: `/purchase/nk?id=${id}`,
    method: 'post',
    data,
  })
}